﻿(function () {
    window.InviteNew = {};
    window.RecommendList = {};
    //**********************************end 20170228 add by zhoug**********************************/
    /*******************************邀请应聘新版***********************************/
    //获取页面的Id，主要用于小精灵页面，暂不使用
    var popUserIDs = "";
    var popSeqIDs = "";
    var popFolderType = "";
    var popJobID = "";
    var popCoid = "";

    InviteNew.Init = function () {
        //投递时间
        $("#divdrop_posttime a").click(function () {
            var id = $(this).parent().attr("id").replace("divdrop_", "");
            $("#hid_" + id).val($(this).attr("value"));
            $("#txt_" + id).val($(this).html());
            $("#divdrop_posttime").hide();
            $("#btnPutTime").click();
            return false;
        });

        $("#ul_selectlist .downBox-s").each(function () {
            $(this).mouseleave(function () {
                if ($(this).children("input[type='text']").attr("readonly")) {
                    $(this).children(".downList").hide();
                    //$(this).children("input[type='text']").css("border-color", "#c4c4c4");
                }
            });
            var obj = $(this);
            $(obj).children("a").click(function () {
                obj.children("div.downList").show();
            });
            $(obj).children("input").click(function () {
                $(this).blur();
                $(this).siblings("a").click();
            });
        });

        //简历投递时间
        $("#txt_posttime").val($("#divdrop_posttime a[value='" + $("#hid_posttime").val() + "']").text());
    }


    InviteNew.getPopData = function (seqids, userids, jobids) {
        popUserIDs = "";
        popSeqIDs = "";
        popFolderType = "";
        popJobID = '';
        popCoid = "";
        popFolderType = $("#hidFolder").val();

        //增加jobid获取
        if ($("#hidJobID") && $("#hidJobID").val() != "") {
            popJobID = $("#hidJobID").val();
        }
        //获取公司id
        if ($("#hidCoid") && $("#hidCoid").val() != "") {
            popCoid = $("#hidCoid").val();
        }
        //end
        if (seqids != null && userids != null) {
            popSeqIDs = seqids;
            popUserIDs = userids;
            return true;
        }
        //多项选择框可用状态
        popSeqIDs = $("#hidCheckedSeqIds").val();
        popUserIDs = $("#hidCheckedUserIds").val();
        if (popSeqIDs == "") {
            popSeqIDs = $("#hidSeqID").val();
            popUserIDs = $("#hidUserID").val();
        }
        if (popSeqIDs == "") {
            EHR.ShowBox(Msg_SelectResume, 300);
            return false;
        }
        return true;
    }
    //打开邀请应聘弹层 type = ELF 说明是小精灵中的邀请
    InviteNew.showDialog = function (userid, coid, jobid, type) {
        //userid = "64688364";
        //coid = "1314631";
        //jobid = "230871011";
        //来源是小精灵页面
        if (type == "ELF") {
            InviteNew.getPopData();
        }
        else {
            if (userid && userid != '') {
                popUserIDs = userid;

            }
            else {
                popUserIDs = EHRResumeList.GetSelectedUserID('chkBox');
                if (popUserIDs == "") {
                    EHR.ShowBox(Msg_SelectResume, 350, 0, "", true);
                    return;
                }
            }
            var downloadNum = $("#hidDownloadNum");
            if (downloadNum && downloadNum.val() == "0" && ((popUserIDs + "").split(',').length == 1)) {
                EHR.ShowBox(Msg_DownloadUserNoDownNum, 350, 0, "", true);
                return;
            }
        }
        var postData = "doType=getcontentnew&userids=" + popUserIDs;
        //coid = "1314631";
        //jobid = "230871011";
        //用于绑定应聘邀请弹框中的公司和职位
        if (coid && jobid) {
            popCoid = coid;
            popJobID = jobid;
            postData += "&coid=" + popCoid + "&jobid=" + popJobID;
        }
        //初始化应聘邀请弹层并显示
        $.ajax({
            type: "POST",
            async: true,
            cache: false,
            dataType: 'xml',
            url: "../ajax/InboxResume/GlobalAppManageAjaxNew.ashx",
            data: postData,
            beforeSend: function (XMLHttpRequest) {
                EHR.ShowMaskDiv();
            },
            success: function (result) {
                var msgType = $(result).find('msgtype').eq(0).text();
                var content = $(result).find('returninfo').eq(0).text();
                if (msgType && msgType == '0') {
                    EHR.ShowBox(content, 350);
                    return;
                }
                var content = $(result).find("defaultContent").eq(0).text();  //弹层的内容
                var invited = $(result).find("invited").eq(0).text();  //判断当前简历是否已被邀请（只针对单份简历）
                //若简历正在邀请中则直接给出提示
                if (invited == "1") {
                    EHR.ShowBox(invitedMsg, 350, 0, "", true);
                    return;
                }
                if (content != "") {
                    //$("#divCtlInviteDialog").html(content);
                    //绑定弹层数据
                    var defCompany = $(result).find("defaultcompany").eq(0).text();
                    var defCoid = $(result).find("defaultcoid").eq(0).text();
                    var defJobName = $(result).find("defaultjobname").eq(0).text();
                    var defJobId = $(result).find("defaultjobid").eq(0).text();
                    var companyList = $(result).find("companylist").eq(0).text();
                    var jobList = $(result).find("joblist").eq(0).text();
                    var strEmail = $(result).find("email").eq(0).text();
                    var defContent = $(result).find("defaultContent").eq(0).text();
                    var contentLen = $(result).find("contentlen").eq(0).text();
                    var strScript = $(result).find("strscript").eq(0).text();
                    if (jobList == "") {
                        jobList = invite_SelectNoneAlert;
                    }
                    $("#txt_invite_company").attr("value", defCompany).attr("value1", defCoid);
                    $("#divdrop_company").html(companyList);
                    $("#txt_invite_position").attr("value", defJobName).attr("value1", defJobId);
                    if (defJobName == invite_PleaseSelect)
                        $("#txt_invite_position").css("color", "#999");
                    $("#ul_invite_positionlist").html(jobList);
                    $("#txt_invite_content").val(defContent);
                    $("#txt_invite_email").val(strEmail);
                    $("#invite_contentNum").html(contentLen);
                    $("#txt_invite_messagetitle").val(inviteSunject);
                    $("#divCtlInviteDialog").append(strScript);
                    $("#invite_txtQueryJobName").val("");
                    //初始化错误提示
                    $("#company_err").hide();
                    $("#position_err").hide();
                    $("#messagetitle_err").hide();
                    $("#content_err").hide();
                    $("#email_err").hide();
                    $("#div_invite_company").removeClass("active");
                    $("#txt_invite_company").removeClass("Common_onHere");
                    $("#div_invite_position").removeClass("active");
                    $("#txt_invite_position").removeClass("Common_onHere");
                    $("#div_invite_messagetitle").removeClass("active");
                    $("#div_invite_content").removeClass("active");
                    $("#div_invite_email").removeClass("active");
                    $("#chk_invite_SendSMS").attr("checked", "checked");
                    $("#divdrop_company").hide();
                    $("#divdrop_position").hide();
                    //显示邀请应聘弹层
                    EHR.ShowDivBox("#divCtlInviteDialog");
                }
            },
            complete: function (XMLHttpRequest, textStatus) {
                EHR.CloseMaskDiv();
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                EHR.CloseMaskDiv();
            }
        });
    }

    //打开选择职位弹层
    InviteNew.showJobs = function () {
        $("#ctlInvite_errMsg").html("");
        if ($("#ctlInvite_divJobquery").is(":hidden")) {
            $("#ctlInvite_divJobquery").show();
        }
    }

    //查询获取职位列表，根据选择的公司id和职位名称去查询职位列表
    InviteNew.queryJobs = function () {
        var queryJobName = $.trim($("#invite_txtQueryJobName").val());
        var coid = $("#txt_invite_company").attr('value1');
        $.ajax(
            {
                type: "POST",
                async: true,
                cache: false,
                dataType: 'xml',
                url: "../ajax/InboxResume/GlobalAppManageAjaxNew.ashx",
                data: "dotype=getjoblist&jobname=" + escape(queryJobName) + "&coid=" + coid,
                beforeSend: function (XMLHttpRequest) {
                    $("#ul_invite_positionlist").html($("#divAjaxLoading01").html());
                },
                success: function (result) {
                    $("#ul_invite_positionlist").html("");
                    var jobList = $(result).find("joblist").eq(0).text()
                    if (jobList != "") {
                        $("#ul_invite_positionlist").html(jobList);
                    }
                    else {
                        $("#ul_invite_positionlist").html(invite_SelectNoneAlert);
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                }
            });
    }

    //打开确认对话框
    InviteNew.confirm = function () {
        if (InviteNew.check()) {
            var inviteCount = (popUserIDs + "").split(',');
            //拼接弹框中的提示
            var inviteConfirmMsg = "<h3 class='fs14'>" + invite_ComfirmInvite + "</h3><p class='hint font_left'>";
            //无忧搜索或暂存夹需显示下载数提示
            if ($("#hidFolder").val().toUpperCase() == "TEMP") {
                inviteConfirmMsg += invite_DownloadHint.format(inviteCount.length, "<img src='" + ImagePath + "commonnew/loading2.gif' alt='loading2' />") + "<a href='../CommonPage/ProductPurchase.aspx?Type=R' target='_blank' style='display:none;' id='invite_buy_Down' class='delfault'>" + invite_ContactBuy + "</a>" + "<br/>";
            }
            //显示短信剩余数提示
            if ($("#chk_invite_SendSMS").is(":checked")) {
                inviteConfirmMsg += invite_SMSSendHint.format(inviteCount.length, "<img src='" + ImagePath + "commonnew/loading2.gif' alt='loading2' />") + "<a href='../CommonPage/ProductPurchase.aspx?Type=R' target='_blank' style='display:none;' id='invite_buy_MSG' class='delfault'>" + invite_ContactBuy + "</a>";
            }
            inviteConfirmMsg += "</p>";
            inviteConfirmMsg += "<p class='hint font_left red' style='display:none;' id = 'invite_nosufficientSMS'>" + invite_NoSufficientSMS + "</p>";

            inviteConfirmMsg += "<a href='javascript:void(0)' class='panel_btn_s' id ='invite_confirm_OK'>" + inviteOK + "</a>";
            inviteConfirmMsg += "<a href='javascript:void(0)' class='panel_btn_s' id = 'invite_confirm_Cancel'>" + inviteCancel + "</a>";
            $("#invite_comfirm_content").html(inviteConfirmMsg);
            var downNum = 0;
            //显示剩余下载数，如果下载数为0则不让提交，下载数不足时提示购买
            $("#invite_ResumeNum").load("../ajax/GlobalInviteAjax.aspx?dotype=getresumenum", function () {
                downNum = parseInt($("#invite_ResumeNum").text());
                if (downNum < inviteCount.length) {
                    $("#invite_buy_Down").show();
                }
                //if (downNum != 0) {
                $("#invite_confirm_OK").click(function () {
                    InviteNew.submit();
                    EHR.CloseDivBoxTwo("#div_invite_comfirm");
                });
                // }
            });
            //显示剩余短信数，短信数不足时提示购买
            if ($("#chk_invite_SendSMS").is(":checked")) {
                $("#invite_AvailSMSNum").load("../ajax/GlobalInviteAjax.aspx?dotype=getavailsmsnum", function () {
                    var iAvailSMS = parseInt($("#invite_AvailSMSNum").text());
                    //短信数不足
                    if (iAvailSMS < inviteCount.length) {
                        $("#invite_nosufficientSMS").show();
                        //下载数存在且小于所需下载数或者下载数提示不存在时，提示短信在线购买
                        if (downNum >= inviteCount.length || $("#invite_ResumeNum").length == 0) {
                            $("#invite_buy_MSG").show();
                        }
                    }
                });
            }
            $("#pAlertContent").html(invite_MsgAlert);
            EHR.ShowDivBoxTwo("#div_invite_comfirm");
            $("#invite_confirm_OK").unbind();
            //人才夹中不显示当前还剩多少下载数，但需要绑定提交事件
            if ($("#invite_ResumeNum").length == 0) {
                $("#invite_confirm_OK").click(function () {
                    InviteNew.submit();
                    EHR.CloseDivBoxTwo("#div_invite_comfirm");
                });
            };
            $("#invite_confirm_Cancel").click(function () {
                EHR.CloseDivBoxTwo("#div_invite_comfirm");
            });
        }
    }

    //显示提示信息对话框
    InviteNew.showMessage = function (msg, closeEvent) {
        $("#CtlInviteConfirm_content").html(msg);
        $("#divCtlInviteConfirm_Cancel").hide();
        $("#divCtlInviteConfirm_OK").unbind();
        $("#divCtlInviteConfirm_OK").click(function () {
            $("#divCtlInviteConfirm").dialog("close");
        });
        if (closeEvent) {
            $("#divCtlInviteConfirm").dialog({
                close: closeEvent
            });
        }
        else {
            $("#divCtlInviteConfirm").dialog({
                close: function () { }
            });
        }
        $("#divCtlInviteConfirm").dialog("open");
    }

    //重置职位下拉框
    InviteNew.resetJobDdl = function () {
        $("#select_ctlInvite_jobs").text(invite_PleaseSelect);
        $("#select_ctlInvite_jobs").attr("selectid", "");
    }

    //输入验证
    InviteNew.check = function () {
        var inviteErrMsg = "";
        var success = true;
        //发件公司不能为空
        if ($("#txt_invite_company").val() == null || $("#txt_invite_company").val().length == 0) {
            InviteNew.showErrorTemp("company", invite_SelectCompanyErr);
            success = false;
        }
        //推荐职位不能为空
        if ($("#txt_invite_position").val() == null || $("#txt_invite_position").val().length == 0 || invite_PleaseSelect == $("#txt_invite_position").val()) {
            InviteNew.showErrorTemp("position", invite_SelectPositionErr);
            success = false;
        }
        //信件主题不能为空
        if ($("#txt_invite_messagetitle").val() == null || $("#txt_invite_messagetitle").val().length == 0) {
            InviteNew.showErrorTemp("messagetitle", invite_MsgSublectErr);  //信件主题的错误提示信息需要修改
            success = false;
        }
        //信件内容不能为空
        if ($("#txt_invite_content").val().replace(/\s/gi, "").length < 1) {
            InviteNew.showErrorTemp("content", invite_ContentEmpty);
            success = false;
        }
        else {
            if (HasHtmlTag($("#txt_invite_content").val())) {      //信件内容不能含有html标签
                InviteNew.showErrorTemp("content", common_hasHtmlTag.replace("{0}", common_Content));
                success = false;
            }
        }
        //回复邮箱是否合法
        if (!checkEmail($("#txt_invite_email").val())) {
            InviteNew.showErrorTemp("email", invite_RevRefEmail);
            success = false;
        }
        return success;
    }

    //邀请预览
    InviteNew.preview = function () {
        if (InviteNew.check()) {
            var form = $("<form/>").attr('action', '../InboxResume/InboxInvitePreview.aspx').attr('method', 'post').attr('target', '_blank');
            var input = '';
            var inviteUserId = popUserIDs;
            var inviteCoId = $("#txt_invite_company").attr("value1");
            var inviteJobId = $("#txt_invite_position").attr("value1");
            var inviteMsg = encodeURIComponent($("#txt_invite_content").val());
            var strPostdata = { "userId": popUserIDs, "coid": inviteCoId, "jobid": inviteJobId, "msg": inviteMsg };
            $.each(strPostdata, function (i, n) {
                input += '<input type="hidden" name="' + i + '" value="' + n + '" />';
            });
            form.append(input).appendTo("body").css('display', 'none').submit();
        }
    }

    //提交邀请应聘
    InviteNew.submit = function (extraParam) {
        //先获取必要信息，公司、职位、信件主题、信件内容、回复邮箱
        var inviteCoId = $("#txt_invite_company").attr('value1');
        var inviteJobId = $("#txt_invite_position").attr("value1");
        var inviteMsg = encodeURIComponent($("#txt_invite_content").val());
        var inviteReplyTo = $("#txt_invite_email").val();
        var inviteSendSMS = $("#chk_invite_SendSMS").is(":checked");
        var msgSubject = $("#txt_invite_messagetitle").val();

        var strWhere = "";
        if (gid('hidWhere') != null) strWhere = escape(encodeURIComponent(gid('hidWhere').value)); //记录搜索条件日志，列表页面应该是这样获取的，但可能对于小精灵页面有所不同
        //是否是简历详情页中的推荐简历
        var hidTxtIsRecommended = $("#hidIsRecommended");
        var strRecommended = "";
        if (hidTxtIsRecommended && hidTxtIsRecommended.length > 0) {
            if (hidTxtIsRecommended.val() == "1") {
                strRecommended = "1";
            }
        }
        var doType = "";
        var ajaxPage = "";
        if ($("#hidFolder").val().toUpperCase() == "TEMP") {
            ajaxPage = "Resume/GlobalDownload.aspx";
            doType = "downloadandinvite";
        }
        else {
            ajaxPage = "GlobalInviteAjax.aspx";
            doType = "invite";
        }
        //popUserIDs = "125078";
        var strPostdata = { "doType": doType,
            "invite": "y",
            "userId": popUserIDs,
            "coid": inviteCoId,
            "jobid": inviteJobId,
            "msg": inviteMsg,
            "replyto": inviteReplyTo,
            "sendsms": inviteSendSMS,
            "strWhere": strWhere,
            "recommend": strRecommended,
            "msgsubject": msgSubject,
            "isNew": "1"
        };

        if (extraParam != null) {
            var extraData = InviteNew.par2Json(extraParam);
            $.extend(strPostdata, extraData)
        }
        EHR.Common_AsyncHandle("POST", "xml", ajaxPage, strPostdata, InviteNew.processResult);
    }

    //邀请应聘ajax返回结果
    InviteNew.processResult = function (result) {
        EHR.CloseDivBox("#divCtlInviteDialog")
        if (typeof (result) != 'object') return false;
        var msgtype = $(result).find("msgtype").eq(0).text(); //服务器返回状态1为成功11为定制0其他情况为失败
        var returninfo = $(result).find("returninfo").eq(0).text(); //服务器返回的信息

        if (msgtype == "11")    //11为需要定制情况
        {
            $("#invite_customized_content").html(returninfo);
            $("#p_customized_alert").html(invite_SelectNumber);
            EHR.ShowDivBox("#div_invite_customized");
        }
        else if (msgtype == "1") //邀请应聘成功
        {
            if (!$("#div_invite_customized").is(":hidden")) {
                EHR.CloseDivBox("#div_invite_customized");
            }
            var strSuccess = "<h3 class='fs14 hint'>" + inviteSendSuccess + "</h3>";
            if ($("#hidFolder").val().toUpperCase() == "TEMP")//下载的简历需要刷新页面
            {
                EHR.ShowBox(strSuccess + returninfo, 350, 0, "InviteNew.refrashPage()", true);
            }
            else {
                EHR.ShowBox(strSuccess + returninfo, 350, 0, "", true);
            }
        }
        else {  //邀请失败
            if (returninfo.indexOf(invite_RepeatErr) > -1)
                EHR.ShowBox(invite_RepeatErr, 350, 0, "", true);
            else {
                //如果异常报错，页面显示获取数据异常！
                if (returninfo == "") returninfo = inviteExceptionData;
                //弹出错误信息
                if ($("#div_invite_customized").is(":hidden")) {
                    EHR.ShowBox(returninfo, 350, 0, "", true);
                }
                else {
                    EHR.ShowBoxTwo(returninfo, 350, 0, "", true);
                }
            }
        }
    }
    //获取用户定制层传回参数串
    InviteNew.GetUserCustomizeUrlPara = function () {
        var customUrlPara = "";
        if (document.getElementById('chkRememberMe') != null) {
            if (document.getElementById('chkRememberMe').checked) {
                customUrlPara += "&rememberMe=1";
            }
            if (document.getElementById('rdbCustomTime').checked) {
                customUrlPara += "&c=0&custom=1";
            } else if (document.getElementById('rdbCustomArea').checked) {
                customUrlPara += "&c=0&custom=2";
            }
        }
        return customUrlPara;
    }
    //错误提示
    InviteNew.showErrorTemp = function (type, errocontent) {
        var error = $("#" + type + "_err");
        if (error.length > 0) {
            error.html("");
            error.html("<i class='icon-exclamation-sign'></i>" + errocontent);
            error.show();
            $("#div_invite_" + type).addClass("active");
        }
    };
    //选择职位
    InviteNew.positionOK = function () {
        var selInviteJob = $('input:radio[name="rdoInviteJob"]:checked');
        if (selInviteJob && selInviteJob.length > 0) {
            $("#txt_invite_position").val(selInviteJob.parent().text());
            $("#txt_invite_position").css("color", "");
            $("#txt_invite_position").attr('value1', selInviteJob.val());
            $("#divdrop_position").hide();
            $("#txt_invite_position").removeClass("Common_onHere");
            $("#position_err").hide();
        }
        else {
            //如果没有选择职位则提示需选择职位
            EHR.ShowBoxTwo(selectPosition, 350, 0, '', true);
            return;
        }
    };
    //公司下拉触发事件
    InviteNew.selectCompany = function (obj) {
        if (obj) {
            var coid = $(obj).attr("value");
            if (coid == $("#txt_invite_company").attr('value1')) return;
            var name = $(obj).text();
            $("#txt_invite_company").val(name);
            $("#txt_invite_company").attr('value1', coid);
            if (coid) {
                InviteNew.GetPositiondroplist(coid);
                $("#txt_invite_position").val(invite_PleaseSelect);
                $("#txt_invite_position").css("color", "#999");
            }
        }
    };
    //根据coid获取职位列表
    InviteNew.GetPositiondroplist = function (coid) {
        var postData = { "doType": "GetPositionList", "coid": coid };
        $.ajax(
          {
              type: "post",
              async: true,
              dataType: 'xml',
              url: "../Ajax/InboxResume/GlobalAppManageAjaxNew.ashx",
              data: postData,
              beforeSend: function (XMLHttpRequest) {
                  $("#ul_invite_positionlist").html($("#divAjaxLoading01").html());
              },
              success: function (result) {
                  var jobList = $(result).find("joblist").eq(0).text();
                  if (jobList == "") {
                      jobList = invite_SelectNoneAlert;
                  }
                  $("#ul_invite_positionlist").html(jobList);
              },
              error: function (XMLHttpRequest, textStatus, errorThrown) {

              }
          });
    };
    //刷新当前页面
    InviteNew.refrashPage = function () {
        //location = location;
        post_to_url(window.location.href, {}, 'form1');
    };
    //url参数转成json格式对象
    InviteNew.par2Json = function (string, overwrite) {
        var obj = {},
            pairs = string.split('&'),
            d = decodeURIComponent,
            name,
            value;
        $.each(pairs, function (i, pair) {
            pair = pair.split('=');
            name = d(pair[0]);
            value = d(pair[1]);
            obj[name] = overwrite || !obj[name] ? value : [].concat(obj[name]).concat(value);
        });
        return obj;
    };
    //恢复模板
    InviteNew.resetInviteContent = function () {
        $("#txt_invite_content").val(invite_MsgDefaultContent);
        $("#invite_contentNum").html(invite_ContentNum.replace('{0}', invite_MsgDefaultContent.length).replace('{1}', 1000));
        $("#content_err").hide();
        $("#div_invite_content").removeClass("active");
    };

    /*---------------------------应聘管理弹框-----------------------------------------*/

    //触发div下拉框

    $("[id$='_invite_company']").live('click', function () {
        if ($("#divdrop_company").is(":hidden")) {
            $("#divdrop_company").show();
            $("#txt_invite_company").addClass("Common_onHere");
        }
        else {
            $("#divdrop_company").hide();
            $("#txt_invite_company").removeClass("Common_onHere");
        }
    });
    $("[id='invite_position']").live('click', function () {
        if ($("#divdrop_position").is(":hidden")) {
            $("#divdrop_position").show();
            $("#txt_invite_position").addClass("Common_onHere");
            $('#position_err').hide();
            $('#div_invite_position').removeClass('active');
        }
        else {
            $("#divdrop_position").hide();
            $("#txt_invite_position").removeClass("Common_onHere");
        }
    });

    $("[id^='txt_invite_']").live('click', function () {

        var controlId = $(this).attr('id').replace('txt_invite_', '');
        if (controlId) {
            $("#" + controlId + "_err").html('');
            $("#div_invite_" + controlId).removeClass("active");
            $(this).addClass("Common_onHere");
        }
    }).live('blur', function () {
        var controlId = $(this).attr('id').replace('txt_invite_', '');
        if (controlId && controlId != 'company' && controlId != 'position')
            $(this).removeClass("Common_onHere");
    });
    //限制邀请应聘弹框中信件内容的字数限制
    $("[id='txt_invite_content']").live('paste keyup mouseup blur', function () {
        InviteNew.CheckContentLength(1000, this);
    });
    //根据传入的最大长度限制信件内容
    InviteNew.CheckContentLength = function (maxLen, obj) {
        var content = $(obj).val();
        var length = content.length;
        if (length > maxLen) {
            content = content.substring(0, maxLen);
            $(obj).val(content);
            $("#invite_contentNum").html(invite_ContentNum.replace('{0}', maxLen).replace('{1}', maxLen));
        }
        else {
            $("#invite_contentNum").html(invite_ContentNum.replace('{0}', length).replace('{1}', maxLen));
        }
    }

    //用于邀请列表查询（下拉框的出现、隐藏）
    InviteNew.InterviewInvitationInit = function () {
        $("[id^='txt_interview_']").live('click', function () {
            var controlID = $(this).attr('id').replace('txt_interview_', "");
            if ($("#divdrop_" + controlID).is(":hidden")) {
                $("#divdrop_" + controlID).show();
                $(this).css("border-color", "#5191ce");
            }
            else {
                $("[id^='divdrop_']").hide();
                $(this).css("border-color", "");
            }
        });
        $("[id^='icon_']").live('click', function () {
            var controlID = $(this).attr('id').replace('icon_', "");
            if ($("#divdrop_" + controlID).is(":hidden")) {
                $("#divdrop_" + controlID).show();
                $(this).siblings("input").css("border-color", "#5191ce");
            }
            else {
                $("[id^='divdrop_']").hide();
                $(this).siblings("input").css("border-color", "");
            }
        });
        $("[id^=div_interview_]").live('mouseleave', function () {
            var controlID = $(this).attr('id').replace('div_interview_', "");
            if (controlID) {
                $("#divdrop_" + controlID).hide();
                $(this).children(0).css("border-color", "");
            }
        });
        $("#SerachDate").live("click", function () {
            $(this).css("border-color", "#5191ce");
        }).live("blur", function () {
            $(this).css("border-color", "");
        })
        InviteNew.getListData("status");
        InviteNew.getListData("userName");
    }
    //统一控制邀请查询列表中搜索区域的下拉选择事件
    InviteNew.getListData = function (type) {
        if (type) {
            $("[id^='dic_" + type + "_']").live('click', function () {
                var selectData = $(this).attr("id").replace('dic_' + type + '_', '');
                var text = $(this).text();
                $("#hid_" + type).val(selectData);
                $("#txt_interview_" + type).val(text);
                if (text == '不限')
                    $("#txt_interview_" + type).css('color', '#c4c4c4');
                else
                    $("#txt_interview_" + type).css('color', '');
                $("#divdrop_" + type).hide();
            })
        }
    }
    /*排序(字段)*/
    InviteNew.setOrderByColumn = function (field) {
        $("#hidSortNeedUsed").val(field);
        $("#btnSort")[0].click();
    };
    //无忧推荐和人才夹匹配全选时统一控制卡片被选中的状态
    RecommendList.setDivActive = function (obj) {
        $('div[id^="divdetail_"]').each(function () {
            if ($(obj).attr('checked')) {
                if (!$(this).hasClass('list-detailed-active')) {
                    $(this).addClass('list-detailed-active');
                }
            }
            else {
                if ($(this).hasClass('list-detailed-active')) {
                    $(this).removeClass('list-detailed-active');
                }
            }
        })
    };
    //对人才夹匹配页面的列表中职能、行业、公司的字数进行限制
    RecommendList.limitTxt = function (dom, num) {
        var dom = $(dom)
        var arrspan = dom.find('span')
        var len = arrspan.length
        for (var i = 0; i < len; i++) {
            if ($(arrspan[i]).text().length > num) {
                $(arrspan[i]).text($(arrspan[i]).text().substr(0, num) + '...')
            }
        }
    };

})();